package fun.stgoder.bmwf.auth.service;

import fun.stgoder.bmwf.auth.client.Test1Client;
import fun.stgoder.bmwf.auth.client.Test2Client;
import fun.stgoder.bmwf.core.domain.R;
import fun.stgoder.bmwf.core.domain.dto.Test1DTO;
import fun.stgoder.bmwf.core.domain.dto.Test2DTO;
import io.seata.spring.annotation.GlobalTransactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TestService {
    @Autowired
    Test1Client test1Client;
    @Autowired
    Test2Client test2Client;

    @GlobalTransactional(rollbackFor = Exception.class)
    public R<List<Test2DTO>> f1(String p) {
        R<List<Test1DTO>> r1 = test1Client.f1(p);
        r1.check();
        R<List<Test2DTO>> r2 = test2Client.f1(p);
        r2.check();
        return r2;
    }
}
